<?php
/**
 * Template Name: About
 **/ 
get_header(); 
if(have_posts()) : while(have_posts()) : the_post(); ?>
<div class="about-page">
    <?php
    
    $page_bg = get_field("background_image", get_the_ID());
    $bg_img = '';
    if(!empty($page_bg)) {
        $bg_img = 'style="background: url('.dynamic_url($page_bg['url']).') left center;background-size: 100% 100%; background-repeat: no-repeat;"';
    } 
    ?>
    <div class="container">
        <div class="content-inner">
            <?php
            $head_img = get_field('header_image', get_the_ID());
            $head_content = get_field('header_content', get_the_ID());
            $head_bg_color = get_field('header_background_color', get_the_ID());
            if(!empty($head_img) || !empty($head_content)) :
            ?>
                <div class="head-section" style="background-color: <?php echo $head_bg_color; ?>">
                    <div class="row">
                        <div class="col-sm-6">
                            <h1><?php the_title(); ?></h1>
                            <div class="head-content">
                                <?php
                                $head_content = apply_filters('the_content', $head_content);
                                _e($head_content); ?>
                            </div>
                        </div>
                        <div class="col-sm-6">
                            <?php
                            if(!empty($head_img)) : ?>
                                <div class="head-img">
                                    <img src="<?php echo dynamic_url($head_img['url']); ?>" alt="<?php the_title();?>"/>
                                </div>
                            <?php endif; ?>
                        </div>
                    </div>
                </div>
            <?php endif; ?>
            <div class="content-background" <?php echo $bg_img; ?>>
                <div class="main-content">
                    <?php the_content(); ?>
                    
                    <?php /*<div class="involved-title">
                        <?php
                        $projects_title = new WP_Query(array(
                            'post_type' => 'project_title',
                            'posts_per_page' => -1,
                            'order' => 'ASC',
                            'orderby' => 'menu_order'
                        ));
                        if($projects_title->have_posts()) :
                            $count = $row = 0;
                            $limit_row = 7;
                            $finish=0;
                            ?>
                            <div class="project-title">
                                <?php
                                while($projects_title->have_posts()) :
                                    $projects_title->the_post();
                                    if($count == 0) : ?>
                                        <ul class="project-row">
                                        <?php endif; $count ++; ?>
                                        <?php if ($row == 0 && $finish==0): 
                                                $limit_row = 4;
                                                $finish=1;
                                        ?>
                                            <li class="title">
                                                <h1><?php _e("These are titles we have been involved with so far", THB_THEME_NAME); ?></h1>
                                            </li>
                                        <?php elseif ($row > 0):?>
                                        <?php $limit_row = 7;?>
                                        <?php endif;?>
                                        <?php
                                        if(has_post_thumbnail(get_the_ID())) :
                                            $project_thumb = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), 'involved-title');
                                            $project_thumb = dynamic_url($project_thumb[0]); ?>
                                            <li><img src="<?php echo $project_thumb; ?>" alt="<?php the_title(); ?>"/></li>
                                        <?php endif; ?>

                                        <?php if($count == $limit_row) : $row ++; $count = 0; ?>
                                        </ul>
                                    <?php endif; ?>
                                <?php endwhile; ?>
                            </div>
                        <?php endif; 
                        wp_reset_postdata(); ?>
                    </div>*/ ?>

                    <?php
                    $teams = new WP_Query(array(
                        'post_type' => 'team',
                        'posts_per_page' => -1,
                        'order' => 'ASC',
                        'orderby' => 'menu_order'
                    ));
                     if($teams->have_posts()) :
                    ?>
                   <div class="content-team relative">
                        <h1>meet our team</h1>
                        <div> <!--*id="carousel" -->
                            <ul class="bxslider">
                                <?php
                                 while($teams->have_posts()) :
                                        $teams->the_post();

                                        if(has_post_thumbnail(get_the_ID())) {
                                            $team_thumb = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), 'team');
                                            $team_thumb = dynamic_url($team_thumb[0]);
                                        } else {
                                            $team_thumb = get_template_directory_uri().'/assets/images/team-member-default.jpg';
                                        }
                                ?>
                                <li><img src="<?php echo $team_thumb; ?>" alt="<?php the_title(); ?>">
                                    <h4><?php the_title(); ?></h4>
                                    <span><?php the_field('positions')?></span>
                                </li>
                                <?php endwhile; ?>
                            </ul>
                        </div>
                       
                    </div>
                    
                    <?php endif; 
                    wp_reset_postdata(); ?>
                </div>
            </div>
            </div>
        </div>
    </div>
</div>
<?php
endwhile; endif; 
get_footer(); ?>